big_integer

A data type that represents large integers with high precision, capable of handling very large numbers. Uses java.math.BigInteger internally.

Since

0.12.0

Constructors

Link copied to clipboard
pure constructor(s: text)

Creates a big_integer from a decimal string representation, possibly with a sign. Fails if the string is not valid.

pure constructor(value: integer)

Creates a big_integer from an integer.

Properties

Link copied to clipboard
val MAX_VALUE: big_integer = 1e+131072

Maximum value ((10^131072)-1)

Link copied to clipboard
val MIN_VALUE: big_integer = -1e+131072

Minimum value (-(10^131072)+1)

Link copied to clipboard
val PRECISION: integer = 131072

The maximum number of digits (131072)

Functions

Link copied to clipboard
pure function abs(): big_integer

Absolute value of the big_integer.

Link copied to clipboard
pure static function from_bytes(value: byte_array): big_integer

Creates a big_integer from a byte_array.

Link copied to clipboard
pure static function from_bytes_unsigned(value: byte_array): big_integer

Creates a big_integer from an unsigned byte_array.

Link copied to clipboard
pure static function from_hex(value: text): big_integer

Creates a big_integer from a hexadecimal string representation

Link copied to clipboard
pure static function from_text(value: text): big_integer

Creates a big_integer from a text representation

pure static function from_text(value: text, radix: integer): big_integer

Creates a big_integer from a string representation with a specific base (radix, from 2 to 36).

Link copied to clipboard
pure function max(value: big_integer): big_integer

Maximum of two big_integer values.

pure function max(value: decimal): decimal

Maximum of a big_integer and a decimal value.

Link copied to clipboard
pure function min(value: big_integer): big_integer

Minimum of two big_integer values.

pure function min(value: decimal): decimal

Minimum of a big_integer and a decimal value.

Link copied to clipboard
pure function pow(exponent: integer): big_integer

Raises this big_integer to the power of the given exponent. Can be used in a database at-expression.

  1. The exponent cannot be negative.

  2. Error on overflow, if the result is out of integer or big_integer range.

  3. If the exponent is 0, the result is always 1; if the exponent is 1, the result is the original value.

Link copied to clipboard
pure function sign(): integer

Returns -1, 0, or 1 depending on the sign.

Link copied to clipboard
pure function to_bytes(): byte_array

Converts this big_integer to a byte_array.

Link copied to clipboard
pure function to_bytes_unsigned(): byte_array

Converts this big_integer to an unsigned byte_array.

Link copied to clipboard
pure function to_decimal(): decimal

Converts this big_integer to a decimal value.

Link copied to clipboard
pure function to_hex(): text

Converts this big_integer to an unsigned hexadecimal representation.

Link copied to clipboard
pure function to_integer(): integer

Converts this big_integer to an integer value.

Link copied to clipboard
pure function to_text(): text

Converts this big_integer to a decimal string representation.

pure function to_text(radix: integer): text

Converts this big_integer to a string representation with a specific base (radix, from 2 to 36).